package util;

import app.Model;
import definitions.Constants;
import entities.Member;

/**
 * Checks if User is authorizated to see certain options / buttons
 * 
 * @author MK
 * 
 */
public class Auth {

	public static Boolean getAuthorization(Member member, Model model) {
		try {
			Member loggedInmember = model.getLoggedInUser().getMember();
			String userRole = loggedInmember.getRole();

			if (userRole.equals(Constants.ROLE_COACH)) {
				return true;
			} else if (loggedInmember.equals(member)) {
				return true;
			} else {
				return false;
			}
		} catch (NullPointerException npe) {
			// means Admin is logged In
			return true;
		}
	}
}